#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
class Solution {
public:
    struct compare {
        bool operator()(pair<string, int> a, pair<string, int> b)
        {
            return a.second > b.second;
        }
    };

    vector<string> topKFrequent(vector<string>& words, int k) {
        map<string, int> mp;
        for (auto s : words)
        {
            mp[s]++;
        }
        vector<pair<string, int>> ret;
        for (auto e : mp)
        {
            ret.push_back(e);
        }
        compare _compare;
        stable_sort(ret.begin(), ret.end(), _compare);
        vector<string> result;
        for (int i = 0; i < k; i++)
        {
            result.push_back(ret[i].first);
        }
        return result;
    }
};
int main() {
    return 0;
}
